package fastjsonDemo.JSONDemo.AnnotationDemo.JSONType;

import com.alibaba.fastjson.JSON;
import org.junit.Test;

public class JSONTypeDemo {
	static Pojo1 pojo1;
	static Pojo2 pojo2;

	static {
		pojo1 = new Pojo1();

		pojo1.setId(11).setName("名字1").setPassword("123456").setPhone("13502141419")
				.setSex("男");

		pojo2 = new Pojo2();
		pojo2.setId(11).setName("名字1").setPassword("123456").setPhone("13502141419")
				.setSex("男");
	}


	/**
	 * 演示JSONType
	 */
	@Test
	public void ceui1() {
		String jsonString = JSON.toJSONString(pojo1);
		System.out.println("jsonString = " + jsonString);  //jsonString = {"name":"名字1","sex":"男"}
	}

	@Test
	public void ceui3() {
		String jsonString = JSON.toJSONString(pojo2);
		System.out.println("jsonString = " + jsonString);   //jsonString = {"name":"名字1","password":"123456","phone":"13502141419"}

	}


}
